package com.qs.education.controllers;
import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONArray;
import com.qs.education.bean.api.ResponseListBean;
import com.qs.education.bean.beans.EducationGradeBean;
import com.qs.education.bean.beans.EducationTeacherGradeClassResponse;
import com.qs.education.bean.entity.EducationTeacherGradeClass;
import com.qs.education.service.IGradeAPIService;

/**
 * @class GradeController
 * @author Leon
 * @description
 * @date Nov 7, 2018
 */
@RestController
@RequestMapping("/grade")
public class GradeController {

	@Autowired
	private IGradeAPIService gradeApiService;
	
	private final Logger log = Logger.getLogger(this.getClass());
	
	/**
	 * @Description 获取所有的年级信息
	 * @author Leon
	 * @date   Nov 12, 2018
	 * @param  
	 * @return ResponseListBean<EducationGradeBean>
	 */
	@RequestMapping("/getAllGrade")
	public ResponseListBean<EducationGradeBean> getAllGrade(){
		log.info("api grade");
		ResponseListBean<EducationGradeBean> listBean = gradeApiService.getAllGrade();
		return listBean;
	}
	
	/**
	 * @Description 完善教师的 班级信息
	 * @author Leon
	 * @date   Nov 12, 2018
	 * @param  
	 * @return EducationTeacherGradeClassResponse
	 */
	@RequestMapping("/batchSaveGradeAndClass")
	public EducationTeacherGradeClassResponse batchSaveGradeAndClass(String params) {
		System.out.println(params);
		List<EducationTeacherGradeClass> grades= JSONArray.parseArray(params,EducationTeacherGradeClass.class);
		System.out.println("api grade batchSaveGradeAndClass ==========");
		for(EducationTeacherGradeClass grade:grades) {
			System.out.println(grade.toString());
		}
		EducationTeacherGradeClassResponse response = new EducationTeacherGradeClassResponse();
		response = gradeApiService.batchSaveGradeAndClass(grades);
		return response;
	}
}
